package com.superbytecode.cloud.redis.lock;

import java.util.concurrent.TimeUnit;

/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: sanskrit
 * @Package: com.superbytecode.cloud.redis.lock
 * @ClassName: Locker
 * @Description: [加锁器接口]
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/8/19 11:14
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.cn Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
public interface Locker {
    /**
     * 加锁
     *
     * @param key         锁key
     * @param releaseTime 自动释放时间
     * @param waitTime    加锁等待时间
     * @param unit        时间单位
     * @return 是否加锁成功
     * @throws InterruptedException InterruptedException
     */
    boolean lock(String key, int releaseTime, int waitTime, TimeUnit unit) throws InterruptedException;

    /**
     * 解锁
     */
    void unlock();
}